home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / vap / sample.c < prev    next >
C/C++ Source or Header  |  1996-07-10  |  2KB  |  84 lines

  1. /*****************************************************************************
  2.  *
  3.  * Program Name:  SAMPLE.VAP
  4.  *
  5.  * Filename:      sample.c
  6.  *
  7.  * Version:          1.0
  8.  *
  9.  * Programmers:      Bryan Sparks
  10.  *                    API Consulting
  11.  *                    Novell Inc
  12.  *
  13.  * Files used:      sap.c vsetup.asm vsap.lib 
  14.  *
  15.  * Comments:      This is a sample VAP. 
  16.  *
  17.  ****************************************************************************/
  18. extern int    Keyword;
  19. unsigned    ConsoleProcess, FirstProcessID, SecondProcessID;
  20.  
  21. main()
  22. {
  23.     int        ccode;
  24.     void     FirstProcessStart();
  25.     void    SecondProcessStart();
  26.  
  27.     VSpawnProcess( FirstProcessStart );
  28.     VSpawnProcess( SecondProcessStart );
  29.  
  30.     /* Notice that I advertise as a NetWare file server. Probably not a */
  31.     /* good idea, but it illustrates the use of the SAP and you can do an */
  32.     /* SLIST to see you VAP. */
  33.     StartSAPOscillationRoutines( "SAMPLE_VAP", 4, 1010 );
  34.  
  35.     ConsoleProcess = VGetProcessID();
  36.     VInitializationComplete();
  37.     while (1) {
  38.         VSleepProcess();
  39.         switch (Keyword) {
  40.         case 0:
  41.             VWakeUpProcess( FirstProcessID );
  42.             break;
  43.         case 1:
  44.             VWakeUpProcess( SecondProcessID );
  45.             break;
  46.         }
  47.     }
  48.  
  49. }
  50.  
  51. void FirstProcess()
  52. {
  53.     FirstProcessID = VGetProcessID();
  54.     VInitializationComplete();
  55.     while (1) {
  56.         VSleepProcess();
  57.         VConsoleError( "First Process is running." );
  58.     }
  59.  
  60. }
  61.  
  62. void SecondProcess()
  63. {
  64.     SecondProcessID = VGetProcessID();
  65.     VInitializationComplete();
  66.     while (1) {
  67.         VSleepProcess();
  68.         VConsoleError( "Second Process is running." );
  69.     }
  70.  
  71. }
  72.  
  73. ConsoleHandler()
  74. {
  75.     VWakeUpProcess( ConsoleProcess );
  76.     return (0);
  77. }
  78.  
  79. DownHandler()
  80. {
  81.     VPrintString( -1, -1, "Sample VAP is down.\n\r", -1 );
  82.     return (0);
  83. }
  84.